﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:data="clr-namespace:MissedMemo.MeatAndCheeseDisc.BusinessLogic;assembly=BusinessObjects"
    xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntry">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="resColors.xaml" />
    </ResourceDictionary.MergedDictionaries>
    
        
    <Style x:Key="OrderTemplateStyle" TargetType="Border" >
        <Setter Property="Padding" Value="5" />
        <Setter Property="Margin" Value="2" />
        <Setter Property="CornerRadius" Value="4" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="{StaticResource brushOrderBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource brushOrderBorder}" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True" >
                <Setter Property="Background" Value="{StaticResource brushOrderBackgroundHighlight}" />
            </Trigger>
            <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}}" Value="True" >
                <Setter Property="BorderBrush" Value="{StaticResource brushOrderBorderHighlight}" />
                <Setter Property="Background" Value="{StaticResource brushSelectedOrderBackground}" />
                <Setter Property="Padding" Value="5,7" />
                <Setter Property="BorderThickness" Value="2" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
    
    
    <local:FormattedTextConverter x:Key="FormattedTextConverter" />
    <local:DeliveryImageConverter x:Key="DeliveryImageConverter" />


    <DataTemplate x:Key="OrderTemplate" DataType="{x:Type data:Order}" >
        
        <Border Style="{StaticResource OrderTemplateStyle}">
            <Grid >
                
                <Grid.Resources>
                    <!-- TextBlock.VerticalAlignment can't be applied via border style -->
                    <Style TargetType="TextBlock">
                        <Setter Property="Foreground" Value="{StaticResource brushOrderText}" />
                        <Setter Property="TextAlignment" Value="Center" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>
                </Grid.Resources>
                
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="{Binding NowServingNumber, Converter={StaticResource FormattedTextConverter}, ConverterParameter='Order# {0}'}" />
                <TextBlock Grid.Column="1" Text="{Binding Customer.Name}" />
                <TextBlock Grid.Column="2" Text="{Binding ElapsedTime, Converter={StaticResource FormattedTextConverter}, ConverterParameter='{}{0:mm:ss}'}" FontSize="14" Foreground="{StaticResource brushTimeElapsedText}" />
                <Image Grid.Column="3" Height="20" Source="{Binding DeliveryRequested, Converter={StaticResource DeliveryImageConverter}}" />
                
            </Grid>
        </Border>
        
    </DataTemplate>

</ResourceDictionary>